home *** CD-ROM | disk | FTP | other *** search
- 10 OPEN "I",#1,"DATA"
- 20 INPUT#1,N :REM Get data count.
- 30 DIM A(N)
- 40 FOR I=0 TO N :REM Get original data set.
- 50 INPUT#1,A(I)
- 60 NEXT I
- 70 CLOSE
- 80 INPUT "Enter desired accuracy ";E
- 90 FOR L=2 TO INT(N/2-.5)
- 100 W=3.141593/L
- 110 FOR I=1 TO N :REM Reconstruct missing values.
- 120 IF I MOD L=0 THEN 190 :REM Branch at sampled values.
- 130 G=0
- 140 FOR J=0 TO N STEP L :REM The Nyquist sum.
- 150 M=W*(I-J)
- 160 G=G+A(J)*SIN(M)/M
- 170 NEXT J
- 180 IF ABS(G-A(I))>E THEN 210 :REM Sum done; test accuracy.
- 190 NEXT I :REM If ok, reconstruct next value.
- 200 NEXT L :REM Increment sampling interval.
- 210 L=L-1 :REM Highest successful sampling interval.
- 220 IF L>1 THEN 260 :REM L=1 means no compression possible.
- 230 PRINT "For an accuracy of +/-";E;"all of this data
- must be kept."
- 240 PRINT "No compressed data file (CDATA) will be generated."
- 250 END :REM Exit.
- 260 OPEN "o",#1,"CDATA" :REM Create compressed data file.
- 270 PRINT#1,N,L :REM Write data count, sampling interval.
- 280 FOR J=0 TO N STEP L :REM Write compressed data set.
- 290 PRINT#1,A(J)
- 300 NEXT J
- 310 CLOSE
- 320 L$="th"
- 330 IF L=2 THEN L$="nd" :REM Tell what you did.
- 340 IF L=3 THEN L$="rd"
- 350 PRINT "Every ";L;L$;" data value has been kept in the
- compressed data file (CDATA)."
- 360 PRINT "The original data set can be reconstructed to
- an accuracy of +/-";E
-